package br.com.skytef.servlet.POS;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import br.com.skytef.beans.POS.Logica;
import br.com.skytef.beans.POS.SystemSession;
import br.com.skytef.entity.MessageEntity;

public class ServletMenuReturn implements Logica {
	private MessageEntity sendMessage = new MessageEntity();

	@Override
	public String executa(HttpServletRequest req, HttpServletResponse res,
			HttpSession sess) throws Exception {

		SystemSession sysSessionRecover = null;
		SystemSession sysSessionNew = null;

		try {
			sysSessionRecover = (SystemSession) sess.getAttribute("SysSession");
			sysSessionNew = sysSessionRecover;
			
			sysSessionNew.setNextServlet("ServletMenuReturn");
			sysSessionNew.setDisplayTitle("Menu Principal");
			sysSessionNew.setNextView("/jsp/POS/MenuPrincipal.jsp");
			

		} catch (Exception e) {

			sendMessage.setTitle("Erro");
			sendMessage.setBody(e.getMessage());

			sysSessionNew.setMessage(sendMessage);
			sysSessionNew.setNextServlet("ServletMenuReturn");
			sysSessionNew.setDisplayTitle("Menu Principal");
			sysSessionNew.setNextView("/jsp/POS/MenuPrincipal.jsp");

		}

		sess.setAttribute("SysSession", sysSessionNew);

		return sysSessionNew.getNextView();
	}
}
